package org.jeecg.modules.qyxx.service.impl;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.qyxx.entity.BgFpHzNdQtzyzc;
import org.jeecg.modules.qyxx.entity.BgFpHzYfQtzyzc;
import org.jeecg.modules.qyxx.entity.BgHzNdYqsq;
import org.jeecg.modules.qyxx.entity.vo.BgFpHzYfQtzyzcSssjQueryVo;
import org.jeecg.modules.qyxx.entity.vo.BgFpHzYfQtzyzcSssjVo;
import org.jeecg.modules.qyxx.enumdemo.RedisKeyConstant;
import org.jeecg.modules.qyxx.mapper.BgFpHzYfQtzyzcMapper;
import org.jeecg.modules.qyxx.service.IBgFpHzYfQtzyzcService;
import org.jeecg.modules.qyxx.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 其他重要支出月汇总数据
 * @Author: ZJJ
 * @Date: 2021-06-22
 * @Version: V1.0
 */
@Service
// @DS("multi-datasource1")申报
public class BgFpHzYfQtzyzcServiceImpl extends MppServiceImpl<BgFpHzYfQtzyzcMapper, BgFpHzYfQtzyzc> implements IBgFpHzYfQtzyzcService {
    @Autowired
    private BgFpHzYfQtzyzcMapper bgFpHzYfQtzyzcMapper;

    @Override
    public Object fpHzYfSfzc(String djxh, List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzYfQtzyzc> wrapper = Wrappers.lambdaQuery(BgFpHzYfQtzyzc.class);
        // List<Object> tjnds =  bgFpHzNdQtzyzcMapper.selectObjs(wrapper);
        List<Object> list = new ArrayList<>();
        for (String tjnd : tjnds) {
            Map<String, Object> map = new HashMap<>();
            wrapper.clear();
            wrapper.eq(BgFpHzYfQtzyzc::getDjxh, djxh).likeRight(BgFpHzYfQtzyzc::getTjyf, tjnd).select(BgFpHzYfQtzyzc::getSfzc);
            List<Object> objs = bgFpHzYfQtzyzcMapper.selectObjs(wrapper);
            map.put("sfzc", objs);
            map.put("tjnd", tjnd);
            list.add(map);
        }
        return list;
    }

    @Override
    public Object fpHzYfDfzc(String djxh, List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzYfQtzyzc> wrapper = Wrappers.lambdaQuery(BgFpHzYfQtzyzc.class);
        // List<Object> tjnds =  bgFpHzNdQtzyzcMapper.selectObjs(wrapper);
        List<Object> list = new ArrayList<>();
        for (String tjnd : tjnds) {
            Map<String, Object> map = new HashMap<>();
            wrapper.clear();
            wrapper.eq(BgFpHzYfQtzyzc::getDjxh, djxh).likeRight(BgFpHzYfQtzyzc::getTjyf, tjnd).select(BgFpHzYfQtzyzc::getDfzc);
            List<Object> objs = bgFpHzYfQtzyzcMapper.selectObjs(wrapper);
            map.put("dfzc", objs);
            map.put("tjnd", tjnd);
            list.add(map);
        }
        return list;
    }

    @Override
    public Object fpHzYfRqzc(String djxh, List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzYfQtzyzc> wrapper = Wrappers.lambdaQuery(BgFpHzYfQtzyzc.class);
        // List<Object> tjnds =  bgFpHzNdQtzyzcMapper.selectObjs(wrapper);
        List<Object> list = new ArrayList<>();
        for (String tjnd : tjnds) {
            Map<String, Object> map = new HashMap<>();
            wrapper.clear();
            wrapper.eq(BgFpHzYfQtzyzc::getDjxh, djxh).likeRight(BgFpHzYfQtzyzc::getTjyf, tjnd).select(BgFpHzYfQtzyzc::getRqzc);
            List<Object> objs = bgFpHzYfQtzyzcMapper.selectObjs(wrapper);
            map.put("sfzc", objs);
            map.put("tjnd", tjnd);
            list.add(map);
        }
        return list;
    }

    public Object fpHzYfYszc(String djxh, List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzYfQtzyzc> wrapper = Wrappers.lambdaQuery(BgFpHzYfQtzyzc.class);
        // List<Object> tjnds =  bgFpHzNdQtzyzcMapper.selectObjs(wrapper);
        List<Object> list = new ArrayList<>();

        for (String tjnd : tjnds) {
            Map<String, Object> map = new HashMap<>();
            wrapper.clear();
            wrapper.eq(BgFpHzYfQtzyzc::getDjxh, djxh).likeRight(BgFpHzYfQtzyzc::getTjyf, tjnd).select(BgFpHzYfQtzyzc::getYscczc);
            List<Object> objs = bgFpHzYfQtzyzcMapper.selectObjs(wrapper);
            map.put("sfzc", objs);
            map.put("tjnd", tjnd);
            list.add(map);
        }
        return list;
    }

    @Override
    public Object fpHzYfRlzc(String djxh, List<String> tjnds) {
        LambdaQueryWrapper<BgFpHzYfQtzyzc> wrapper = Wrappers.lambdaQuery(BgFpHzYfQtzyzc.class);
        // List<Object> tjnds =  bgFpHzNdQtzyzcMapper.selectObjs(wrapper);
        List<Object> list = new ArrayList<>();
        for (String tjnd : tjnds) {
            Map<String, Object> map = new HashMap<>();
            wrapper.clear();
            wrapper.eq(BgFpHzYfQtzyzc::getDjxh, djxh).likeRight(BgFpHzYfQtzyzc::getTjyf, tjnd).select(BgFpHzYfQtzyzc::getRlzc);
            List<Object> objs = bgFpHzYfQtzyzcMapper.selectObjs(wrapper);
            map.put("sfzc", objs);
            map.put("tjnd", tjnd);
            list.add(map);
        }
        return list;
    }

    @Override
    public List<BgFpHzYfQtzyzcSssjVo> listSssjByDjxhAndYears(BgFpHzYfQtzyzcSssjQueryVo vo) {
        return bgFpHzYfQtzyzcMapper.selectSssjByDjxhAndYears(vo);
    }
}
